package com.hrbxlh.virtualization.converter;

import com.hrbxlh.virtualization.dto.ClusterDTO;
import com.hrbxlh.virtualization.param.ClusterCreateParam;
import com.hrbxlh.virtualization.pojo.Cluster;
import com.hrbxlh.virtualization.util.SessionUtil;
import com.hrbxlh.virtualization.vo.ClusterVO;
import org.springframework.beans.BeanUtils;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

/**
 * @author cheer
 */
@Component
public class ClusterDTOToClusterVOConverter implements Converter<ClusterDTO, ClusterVO> {

    @Override
    public ClusterVO convert(ClusterDTO clusterDTO) {
        ClusterVO clusterVO = new ClusterVO();
        BeanUtils.copyProperties(clusterDTO, clusterVO);
        clusterVO.setName(clusterDTO.getClusterName());
        if (clusterVO.getMasterImageName() == null) {
            clusterVO.setMasterImageName("已删除");
        }
        if (clusterVO.getFirstSlaveImageName() == null) {
            clusterVO.setFirstSlaveImageName("已删除");
        }
        if (clusterVO.getSecondSlaveImageName() == null) {
            clusterVO.setSecondSlaveImageName("已删除");
        }
        return clusterVO;
    }
}
